
<form action="" id="setCategory"  method="post">
    <div class="col-xs-12 col-md-12 col-lg-12 padding-none lists _data">
        <div class="col-lg-2 col-md-3 col-xs-5 filed-name text-right">选择分类 :</div>
        <div class="col-lg-3 col-md-5 col-xs-7 filed-from padding-none">
            <div class="input-group">
                <input type="text" value="<?php echo $data[0]['category_name']?>" data-id="<?php echo $data[0]['category_id']?>" class="form-control radius-none" disabled="disabled">
            <span class="input-group-btn">
                <button class="btn btn-success radius-none" type="button">点击选择</button>
            </span>
            </div>
        </div>
        <div class="col-xs-12 col-md-12 col-lg-12 padding-none" style="margin-top: 10px;">
            <div class="col-lg-2 col-md-3 col-xs-5 filed-name text-right">缩略图<pub>*</pub> :</div>
            <div class="col-md-7 filed-from padding-none">
                <img class="thumb _thumb"  data-toggle="tooltip" data-placement="top" title="建议上传100 X 100(px)的.jpg图片" src="<?php echo cutUrl($data[0]['icon'],100,100) ? cutUrl($data[0]['icon'],100,100) : '/statics/common/images/image.png' ?>" data-src="<?php echo cutUrl($data[0]['icon'],100,100) ? cutUrl($data[0]['icon'],100,100) : '/statics/common/images/image.png' ?>" width="100" height="100" style="border-radius: 50px">
            </div>
        </div>
    </div>
    <div class="col-xs-12 col-md-12 col-lg-12 padding-none lists _data">
        <div class="col-lg-2 col-md-3 col-xs-5 filed-name text-right">选择分类 :</div>
        <div class="col-lg-3 col-md-5 col-xs-7 filed-from padding-none">
            <div class="input-group">
                <input type="text" value="<?php echo $data[1]['category_name']?>" data-id="<?php echo $data[1]['category_id']?>" class="form-control radius-none" disabled="disabled">
            <span class="input-group-btn">
                <button class="btn btn-success radius-none" type="button">点击选择</button>
            </span>
            </div>
        </div>
        <div class="col-xs-12 col-md-12 col-lg-12 padding-none" style="margin-top: 10px;">
            <div class="col-lg-2 col-md-3 col-xs-5 filed-name text-right">缩略图<pub>*</pub> :</div>
            <div class="col-md-7 filed-from padding-none">
                <img class="thumb _thumb"  data-toggle="tooltip" data-placement="top" title="建议上传100 X 100(px)的.jpg图片" src="<?php echo cutUrl($data[1]['icon'],100,100) ? cutUrl($data[1]['icon'],100,100) : '/statics/common/images/image.png' ?>" data-src="<?php echo cutUrl($data[1]['icon'],100,100) ? cutUrl($data[1]['icon'],100,100) : '/statics/common/images/image.png' ?>" width="100" height="100" style="border-radius: 50px">
            </div>
        </div>
    </div>
    <div class="col-xs-12 col-md-12 col-lg-12 padding-none lists _data">
        <div class="col-lg-2 col-md-3 col-xs-5 filed-name text-right">选择分类 :</div>
        <div class="col-lg-3 col-md-5 col-xs-7 filed-from padding-none">
            <div class="input-group">
                <input type="text" value="<?php echo $data[2]['category_name']?>" data-id="<?php echo $data[2]['category_id']?>" class="form-control radius-none" disabled="disabled">
            <span class="input-group-btn">
                <button class="btn btn-success radius-none" type="button">点击选择</button>
            </span>
            </div>
        </div>
        <div class="col-xs-12 col-md-12 col-lg-12 padding-none" style="margin-top: 10px;">
            <div class="col-lg-2 col-md-3 col-xs-5 filed-name text-right">缩略图<pub>*</pub> :</div>
            <div class="col-md-7 filed-from padding-none">
                <img class="thumb _thumb"  data-toggle="tooltip" data-placement="top" title="建议上传100 X 100(px)的.jpg图片" src="<?php echo cutUrl($data[2]['icon'],100,100) ? cutUrl($data[2]['icon'],100,100) : '/statics/common/images/image.png' ?>" data-src="<?php echo cutUrl($data[2]['icon'],100,100) ? cutUrl($data[2]['icon'],100,100) : '/statics/common/images/image.png' ?>" width="100" height="100" style="border-radius: 50px">
            </div>
        </div>
    </div>
    <div class="col-xs-12 col-md-12 col-lg-12 lists text-right">
        <input type="submit" name="dosubmit" value="保存" class="btn btn-success radius-none">
        <input type="reset"  value="重置" class="btn btn-info radius-none">
    </div>
</form>
<script>

    //储存节点对象
    var $setting = {}

    $(function(){

        Admin.upload('._thumb',false,function(objects){

            $setting.images = objects;

        });

        $('[data-toggle="tooltip"]').tooltip();

        $('#setCategory button').unbind('click');
        $('#setCategory button').click(function(){

            var _this = $(this);

            $.post(getActivityUrl,{action:'category'},function(result){

                layer.closeAll();
                //console.log(result);

                layer.open({
                    title: '选择一个分类',
                    type: 1,
                    skin: 'layui-layer-rim', //加上边框
                    area: ['30%', '50%'], //宽高
                    content: result,
                    btn: ['选择', '关闭'],
                    yes: function (index, _thisNote) {

                        //获取分类ID
                        var id = $('select',_thisNote).val();
                        var name = $('select  option:selected',_thisNote).data('name');

                        _this
                                .parent()
                                .prev()
                                .val(name)
                                .attr('data-id',id);

                        layer.close(index);

                    },
                });

            });

        });


        //提交数据
        $('#setCategory').unbind('submit');
        $('#setCategory').submit(function(){
            //<?php echo U('Admin/Goods/Category/setCategory')?>



            var data = [],_this = $(this);

            $('._data', _this).each(function(i,v){

                var cate_info = {}

                cate_info.category_name = $('input',$(this)).val();
                cate_info.category_id   = $('input',$(this)).data('id');
                cate_info.icon   = $('img',$(this)).data('src');

                data.push(cate_info);

            });

            $.post("<?php echo U('Admin/Setting/Index/setCategory')?>",{'data':data},function(result){

                showMessage(result.msg,result.code,'','',2000);

            });

            return false;

        });

    });

    //图片上传回调
    function getImageSrc(_this){

        $setting.images.attr('src',cutUrl(_this[0],100,100));
        $setting.images.data('src',_this[0]);

    }
</script>